package com.iaz.tech.tools.common.flow.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iaz.tech.tools.common.flow.IFlowAble;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * do while 语句
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class DowhileFlow extends FlowsGroup {
    /**
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(CatchFlow.class);

	private IFlowAble footerBoundary = null;
	/**
     * 执行流程
     */
    @Override
    public Object executeFlow(Object property) {
        Object result = null;
        try {
            while(true) {
                super.executeFlow(property);
                if (this.footerBoundary != null) {
                    Object return_result = this.footerBoundary.executeFlow(property);
                    if (return_result == null) {
                        break;
                    }
                    if (return_result instanceof Boolean) {
                        if ((Boolean)return_result) {
                            continue;
                        }
                        break;
                    }
                }
            }
        } catch(Exception e) {
            logger.error("do while 异常", e);
        }
        return result;
    }
    /**
     * 执行前处理
     */  
    @Override
    public Object beforeExecute(Object property) {
        Object result = null;
        return result;
    }
    /**
     * 执行后处理
     */
    @Override
    public Object afterExecute(Object property) {
        Object result = null;
        return result;
    }
}
